package re.kitri.common.main;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import re.kitri.common.Paging.PagingUtil;
import re.kitri.common.board.BoardDAO;
import re.kitri.common.board.BoardDTO;
import re.kitri.common.game.GameDTO;
import re.kitri.common.game.GameImple;

/**
 * Servlet implementation class MainView
 */
@WebServlet("/MainView")
public class MainView extends HttpServlet {
	private static final long serialVersionUID = 1L;

	public MainView() {
		super();
	}

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		receivedProcessing(request,response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		receivedProcessing(request,response);
	}
	private void receivedProcessing(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
		String divide = request.getParameter("divide");
		GameDTO gameDTO = new GameDTO();
		GameImple gameImple = new GameImple();
		
		BoardDAO dao = new BoardDAO();
		BoardDTO dto = new BoardDTO(); 
		ArrayList list = dao.MainList(dto);
		System.out.println(dto.getBoard_seq()+"MainView1");

		HttpSession session = request.getSession();
		RequestDispatcher requestDispatcher = null;

		if(divide.equals("main_game_schedule")){
			//System.out.println("��� : MainView?divide=game_schedule");

			request.setAttribute("gameList", gameImple.listSummary());
			request.setAttribute("Main_BOARDLIST", list);
			System.out.println(dto.getBoard_seq()+"MainView2");

			requestDispatcher = request.getRequestDispatcher("totomain.tiles");
			requestDispatcher.forward(request, response);

		}
	}
}
